<%= render  :partial => "apo/navigation" %>

    <div id="content-pri-frame">

      <div id="content-pri-frame-gener">

  <div style="width: 100%; text-align: center; font-weight: bold; font-size: 2em; margin-bottom: 0.5em;">
      Past Events This Semester
  </div>
	<div style="margin-bottom: 0.5em">
  	<% form_tag :action => "old_list" do %>
			Showing:
			<% unless params[:filter].nil? %>
				<%= select "filter", "type",
				[
					["All", nil],
					["Service", "Service"],
					["Fellowships", "Fellowship"],
					["LDCs", "Leadership"],
					["Fundraisers", "Fundraiser"],
					["Active Meetings", "Active Meeting"],
					["Pledge Meetings", "Pledge Meeting"],
					["Dues", "Dues"],
					["Office Hours", "Office Hour"],
					["Committees", "Committee"],
					["Ceremonies", "Ceremony"],
					["Indy Hours", "Indy Hours"],
					["Pledge Reqs", "Pledge Req"],
                    ["Tri-Sectionals", "Tri-Sectionals"],
					["Other", "Other"]
				],
				{:selected => params[:filter][:type]},
				{:onchange => 'this.form.submit();'} %>
			<% else %>
				<%= select "filter", "type",
				[
					["All", nil],
					["Service", "Service"],
					["Fellowships", "Fellowship"],
					["LDCs", "Leadership"],
					["Fundraisers", "Fundraiser"],
					["Active Meetings", "Active Meeting"],
					["Pledge Meetings", "Pledge Meeting"],
					["Dues", "Dues"],
					["Office Hours", "Office Hour"],
					["Committees", "Committee"],
					["Ceremonies", "Ceremony"],
					["Indy Hours", "Indy Hours"],
					["Pledge Reqs", "Pledge Req"],
                    ["Tri-Sectionals", "Tri-Sectionals"],
					["Other", "Other"]
				],
				{},
				{:onchange => 'this.form.submit();'} %>
			<% end %>
		<% end %>
	</div>

	<div class="container eventContainer">

		<div class="cellRow cellRowHeader">
			<div class="cellBlock" style="text-align: left;">
				<%= link_to "Event Name" , :action => "old_list" , :id => @event, :sort_by => "name" %>
			</div>
			<div class="cellBlock" style="text-align: right;">
				<%= link_to "Date" , :action => "old_list" , :id => @event %>
			</div>
			<div class="cellBlock" style="text-align: right;">
				<%= link_to "Time" , :action => "old_list" , :id => @event %>
			</div>
			<div class="cellBlock" style="text-align: right;">
				<%= link_to "Hours" , :action => "old_list" , :id => @event, :sort_by => "hours" %>
			</div>
			<div class="cellBlock">Serv.</div>
			<div class="cellBlock">Lead.</div>
			<div class="cellBlock">Fell.</div>
			<div class="cellBlock">Meet.</div>
            <div class="cellBlock">Fund.</div>
            <div class="cellBlock">TriS.</div>
			<div class="cellBlock" style="text-align: left;">
				MIC
			</div>
			<div class="cellBlock" style="text-align: left;">
				<%= link_to "Type" , :action => "old_list" , :id => @event, :sort_by => "event_type" %>
			</div>
			<div class="cellBlockNoBorder cellBlockNoBorderL">
			</div>
			<% if session[:user].admin? %>
				<div class="cellBlockNoBorder cellBlockNoBorderL">
				</div>
				<div class="cellBlockNoBorder cellBlockNoBorderL">
				</div>
			<% end %>
		</div>

		<% counter = 0 %>
		<% @events.each  do |event| %>
			<div class="cellRow cellRow<%= counter % 2 == 0?1:2 %>">
				<div class="cellBlock">
					<% if session[:user].admin? and event.name.length > 30 %>
						<%= link_to h(event.name[0,29]), :action => "show" , :id => event %>...
					<% else %>
						<%= link_to h(event.name), :action => "show" , :id => event %>
					<% end %>
				</div>
				<div class="cellBlock" style="text-align: right;">
					<%=h event.date.strftime("%A")[0,3]%><%=h event.date.strftime(", %b %d") %>
				</div>
				<div class="cellBlock" style="text-align: right;">
					<%=h event.date.strftime("%I:%M %p") %>
				</div>
				<div class="cellBlock" style="text-align: right;">
					<%=h event.hours %>
				</div>
				<div class="cellBlock" style="text-align: center;">
					<%=h (i = event.additional_service_hours) == 0 ? " " : i %>
				</div>
				<div class="cellBlock" style="text-align: center;">
					<%=h (i = event.additional_leaderships.to_i) == 0 ? " " : i %>
				</div>
				<div class="cellBlock" style="text-align: center;">
					<%=h (i = event.additional_fellowships.to_i) == 0 ? " " : i %>
				</div>
				<div class="cellBlock" style="text-align: center;">
					<%=h (i = event.additional_active_meetings.to_i) == 0 ? " " : i %>
				</div>
				<div class="cellBlock" style="text-align: center;">
					<%=h (i = event.additional_fundraisers.to_i) == 0 ? " " : i %>
				</div>
                <div class="cellBlock" style="text-align: center;">
                    <%=h (i = event.additional_trisecs.to_i) == 0 ? " " : i %>
                </div>
				<div class="cellBlock">
					<% if event.mic_id != nil and event.mic != nil %>
						<%= link_to h(event.mic.full_name) , :controller => "members", :action => "show" , :id => event.mic %>
					<% else %>
						&nbsp;
					<% end %>
				</div>
				<div class="cellBlock">
					<%=h event.event_type %>
				</div>

				<% if session[:user].admin? or event.mic_id == session[:user].id %>
					<% if (event.approved == false) %>
						<div class="cellBlock"><%= link_to "Not Approved", :action => "approve_event", :goto => 'old_list', :id => event.id %></div>
					<% else %>
						<div class="cellBlock"><%= link_to "Approved", :action => "un_approve_event", :goto => 'old_list', :id => event.id %></div>
					<% end %>
				<% else %>
					<% if (event.approved == false)%>
						<div class="cellBlock">Not Approved&nbsp;</div>
					<% else %>
						<div class="cellBlock">Approved&nbsp;</div>
					<% end %>
				<% end %>

				<% if session[:user].admin? %>
				<div class="cellBlockNoBorder cellBlockNoBorderL" style="text-align: center;">
					<%= link_to "edit", :action => "edit", :id => event %>
				</div>
				<div class="cellBlockNoBorder cellBlockNoBorderL" style="text-align: center;">
					<%= link_to "remove", :action => "remove", :id => event %>
				</div>
				<% end %>
			</div>
			<% counter = counter + 1 %>
		<% end %>

	</div>

</div>

    </div>

<%= render :partial => "apo/footer" %>